package com.baosaas.api.baseInfo.controller;

import com.alibaba.fastjson.JSON;
import com.baosaas.api.baseInfo.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/cbbSys")
public class SystemController {
    int x = 0;

    public SystemController() {
        System.out.println("Controller初始化...." + x);
    }

    @Autowired
    private SystemService gateControlService;

    @RequestMapping(value = "/queryCarList")
    @ResponseBody
    public Object queryCarList(String deptId, String requestType, HttpServletResponse response, HttpServletRequest request) {
        try {
            response.setContentType("application/json; charset=utf-8");
            response.setHeader("Access-Control-Allow-Origin", "*");
            response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,PUT");
            response.setHeader("Access-Control-Max-Age", "3600");
            response.setHeader("Access-Control-Allow-Headers", "Content-Type,x-requested-with");
//            String result = gateControlService.queryCarList(deptId, requestType);
            x++;
            return x;
        } catch (Exception e) {
            System.out.println(e.getMessage());
            Map<String, Object> result = new HashMap<String, Object>();
            result.put("resultFlag", "0");
            result.put("resultMemo", "获取车辆列表异常");
            return JSON.toJSONString(result);
        }
    }
}
